/************************************************************************
    filename:   DaterGroupEventMap.h
    created:    21/5/2012
    author:     4Ys

    purpose:    Defines class for Group Event Map objects
*************************************************************************/

#ifndef _DaterGroupEventMap_h_
#define _DaterGroupEventMap_h_

#include "DaterUser.h"
#include "DaterGroupEvent.h"
#include "DaterTime.h"
#include "DaterIteratorBase.h"

#include <map>
#include <string>

namespace Dater
{
	/*!
	\brief
		An entity class contains 21 year calendars front and back.
	*/
	class GroupEventMap
	{
	public:
		enum GroupEventState
		{
			Waiting,
			Accepted,
			Refused
		};
		
		/*!
		\brief
			Constructor for GroupEventMap class.
		*/
		GroupEventMap(int groupID, int groupEventID, User* publisher, const std::string& name,
			const Time& startTime, const Time& finishTime, const Time& createTime, const std::string& description);
		//int getState();
		void setState(int userID, GroupEventState state);
		
		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		GroupEventState getState(int userID);

		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		void setPublisher(User* publisher);

		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		User* getPublisher();

		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		int getGroupID();

		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		int getGroupEventID();

		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		const std::string& getName() const;

		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		const std::string& getDescription() const;

		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		const Time& getCreateTime() const;

		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		const Time& getStartTime() const;

		/*!
		\brief
			Get the CalendarYear of the given year

		\param year
			The year of the Calendar.

		\return
			Pointer to the CalendarYear of the given year
		*/
		const Time& getFinishTime() const;

		/*!
		\brief
			a group of functions to add an event.
		
		\param Event
			a pointer to the new event.
		*/
		void setName(const std::string& name);

		/*!
		\brief
			a group of functions to add an event.
		
		\param Event
			a pointer to the new event.
		*/
		void setDescription(const std::string& description);

		/*!
		\brief
			a group of functions to add an event.
		
		\param Event
			a pointer to the new event.
		*/
		void setCreateTime(const std::string& createTime);

		/*!
		\brief
			a group of functions to add an event.
		
		\param Event
			a pointer to the new event.
		*/
		void setStartTime(const std::string& startTime);

		/*!
		\brief
			a group of functions to add an event.
		
		\param Event
			a pointer to the new event.
		*/
		void setFinishTime(const std::string& finishTime);

	private:
		int _groupID;

		int _groupEventID;

		User* _publisher;

		std::string _name;

		std::string _description;

		Time _createTime;

		Time _startTime;

		Time _finishTime;

		typedef std::map<int, GroupEventState> RelatedUserState;

		RelatedUserState _relatedUserState;
		
		//int getIndex(int userID);
		/*!
		 \brief
			 A processing function to split the order.

		 \param order
		     - a string of order from client to server.

		 \param delimiter
		     - a string which is the charactor to split the order.

		 \param splitedVector
		     - a vector of strings which are tiny orders splited from order.

		 \return
			 Nothing.
		*/
		//void split(std::string const& order, std::string delimiter, std::vector<std::string>& splitedVector);

		GroupEventMap() {};

		public:
			typedef ConstBaseIterator< RelatedUserState > UserStateIterator;

		/*!
		\brief
			Return a EventManager::EventIterator object to iterate over the currently defined Events.
		*/
			UserStateIterator getIterator(void) const;
	};
}
#endif